home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
fish
/
001-100
/
076-100
/
097
/
shm
/
shm_cycle_time.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-18
|
4KB
|
143 lines
/************************************************************************
Cycle Time Requester 1 August 87
************************************************************************/
#include <exec/types.h>
#include <intuition/intuition.h>
#include "shm_defines"
extern struct TextAttr Fnt;
/************************************************************************
Cycle Time Definitions
************************************************************************/
char cycle_time_str[4];
struct IntuiText cycle_time_val_txt =
{1, 3, JAM2, 10, 14, &Fnt, (UBYTE *)cycle_time_str, NL};
struct IntuiText cycle_time_secs_txt =
{1, 0, JAM1, 52, 28, &Fnt, (UBYTE *)"Seconds per colour step", NL};
struct IntuiText cycle_time_txt =
{1, 0, JAM1, 80, 4, &Fnt, (UBYTE *)"CYCLE TIME",
&cycle_time_secs_txt};
struct IntuiText cycle_time_ok_txt =
{1, 0, JAM1, 2, 2, &Fnt, (UBYTE *)"OK", NL};
struct Image cycle_time_ok_img = {0,0, 20,11, 1, NL, 0, 2, NL};
struct Image cycle_time_img;
struct PropInfo cycle_time_prop;
struct Gadget cycle_time_gad =
{
NL,
6, 14, 210, 11,
GADGHCOMP,
GADGIMMEDIATE | RELVERIFY,
PROPGADGET | REQGADGET,
(APTR)&cycle_time_img, NL,
&cycle_time_val_txt,
NL,
(APTR)&cycle_time_prop,
1, NL
};
struct Gadget cycle_time_ok_gad =
{
&cycle_time_gad,
222, 14, 20, 11,
GADGHBOX | GADGIMAGE,
RELVERIFY | ENDGADGET,
BOOLGADGET | REQGADGET,
(APTR)&cycle_time_ok_img, NL,
&cycle_time_ok_txt,
NL, NL, 2, NL
};
struct Requester cycle_time_req;
#define SPX 250
#define SPY 40
SHORT cycle_time_border_coords[] =
{0,0, SPX-1,0, SPX-1,SPY-1, 0,SPY-1, 0,0};
struct Border cycle_time_border =
{
0,0,
1,0, JAM1,
5, &cycle_time_border_coords[0],
NL
};
/************************************************************************
Cycle Time Function
************************************************************************/
int cycle_time(cW,ticks)
struct Window *cW;
int ticks;
{
struct IntuiMessage *message;
struct Gadget *gad;
BOOL loop;
int class,ticks_c;
ModifyIDCMP(cW,GADGETUP | GADGETDOWN | REQCLEAR | MOUSEMOVE);
/* Remember to set REPORTMOUSE flag in window structure
for MOUSEMOVE to work */
cycle_time_prop.Flags = FREEHORIZ | AUTOKNOB;
cycle_time_prop.HorizBody = 0x1000;
sprintf(cycle_time_str,"%3.1f\0",ticks/10.0);
InitRequester(&cycle_time_req);
cycle_time_req.LeftEdge = 250;
cycle_time_req.TopEdge = 25;
cycle_time_req.Width = SPX;
cycle_time_req.Height = SPY;
cycle_time_req.ReqGadget = &cycle_time_ok_gad;
cycle_time_req.ReqText = &cycle_time_txt;
cycle_time_req.BackFill = 3;
cycle_time_req.ReqBorder = &cycle_time_border;
Request(&cycle_time_req,cW);
cycle_time_prop.HorizPot = (int)(65535*ticks)/10;
RefreshGadgets(&cycle_time_ok_gad,cW,NL);
loop = TRUE;
while (loop)
{
Wait(1 << cW->UserPort->mp_SigBit); /* Be good and go to sleep till
Intuition sends a message */
while (message = (struct IntuiMessage *) GetMsg(cW->UserPort))
{
class = message->Class; /* Process all outstanding Messages */
ReplyMsg(message);
if (class == REQCLEAR) loop = FALSE; /* OK selected */
if (class == GADGETDOWN)
gad = (struct Gadget *) message->IAddress;
}
/* MOUSEMOVE events are not acknowledged specifically, but by
generating a message cause the following code to update the
slider */
if (gad->GadgetID == 1)
{
ticks_c = (cycle_time_prop.HorizPot*10)/65535;
if (ticks != ticks_c)
{
/* Update slider only if the value has changed */
ticks = ticks_c;
sprintf(cycle_time_str,"%3.1f\0",ticks/10.0);
RefreshGList(&cycle_time_gad,cW,&cycle_time_req,1);
}
}
}
ModifyIDCMP(cW,MENUPICK | REQCLEAR | INTUITICKS);
return(ticks);
}